#include "PatientInfoLittleWidget.h"
#include "QApplication"

namespace UserManagementSystem {
QString man_path=QApplication::applicationDirPath()+"/res/PatientManager/sort.png";
QString female_path=QApplication::applicationDirPath()+"/res/PatientManager/sort.png";

static QIcon m_manIcon=QIcon(man_path);
static QIcon m_femaleIcon=QIcon(female_path);

PatientInfoLittleWidget::PatientInfoLittleWidget(QWidget* parent)
    :FramelessWidget(parent)
{

    //初始化布局
    m_mainLayout=new QHBoxLayout(this);

    //子布局
    m_subLayout=new QVBoxLayout();

    m_upperLayout=new QHBoxLayout();
    m_lowerLayout=new QHBoxLayout();

    //子控件
    m_profilePic=new QLabel();
    m_patientName=new QLabel();
    m_createTimeLabel=new QLabel();
    m_patientAge=new QLabel();

    m_editPatientBtn=new QPushButton();
    m_deletePatientBtn=new QPushButton();


    InitDedaultLayout();
}

void PatientInfoLittleWidget::InitDedaultLayout()
{
    m_upperLayout->addWidget(m_patientName);
    m_upperLayout->addStretch(1);//添加一个弹簧
    m_upperLayout->addWidget(m_patientAge);


    m_lowerLayout->addWidget(m_createTimeLabel);
    m_lowerLayout->addStretch(1);//添加一个弹簧
    m_lowerLayout->addWidget(m_editPatientBtn);
    m_lowerLayout->addWidget(m_deletePatientBtn);


    m_subLayout->addLayout(m_upperLayout);
    m_subLayout->addLayout(m_lowerLayout);


    m_mainLayout->addWidget(m_profilePic);
    m_mainLayout->addLayout(m_subLayout);
    m_mainLayout->addWidget(m_patientAge);

    InitDefaultStyle();

}

void PatientInfoLittleWidget::InitDefaultStyle()
{
    m_patientName->setText("Patient name");
    m_createTimeLabel->setText("2025/07/16 16:51");
    m_patientAge->setText("Patient Age");
}

void PatientInfoLittleWidget::LoadIcon()
{
    QString man_path=QApplication::applicationDirPath()+"/res/PatientManager/sort.png";
    QString female_path=QApplication::applicationDirPath()+"/res/PatientManager/sort.png";

    m_manIcon.addFile(man_path);
    m_femaleIcon.addFile(female_path);
}

}
